import { post, get } from '../network/http'

/**
 * 委托下单
 * @param data
 * @returns {Promise}
 */
export function order (data) {
  return post('action/v1.0/SendOrderInsert', data)
}

/**
 * 撤单
 * @param data
 * @returns {Promise}
 */
export function revokeOrder (data) {
  return post('action/v1.0/SendOrderAction', { ...data, MemberID: '1001' })
}

/**
 * 获取持仓
 * @returns {Promise}
 */
export function getPosition () {
  return get('query/v1.0/position', {
    MemberID: '1001'
  })
}

/**
 * 获取当前委托
 * @returns {Promise}
 */
export function getCurrentOrder (params) {
  return get('query/v1.0/order', {
    ...params, MemberID: '1001'
  })
}

/**
 * 获取历史委托
 * @returns {Promise}
 */
export function getHistoryOrder (params) {
  return get('query/v1.0/history_order', {
    ...params, MemberID: '1001'
  })
}
